/**
* @file role_activity.h
* @brief 角色活动数据
*/
#ifndef _ROLE_ACTIVITY_H_
#define _ROLE_ACTIVITY_H_

#include <stdint.h>
#include <unordered_map>
#include "../share/time_module.h"

#include "../../3rd/libjson/json.h"


class Player;

class CActivityCount
{
public:
	CActivityCount()
	{
		join_time_ = 0;
		activity_id_ = 0;
		timestamp_ = 0;
	}
	int32_t join_time() { return join_time_; }
	int32_t activity_id() { return activity_id_; }
	void set_join_time(int32_t join_time) { join_time_ = join_time; }
	void set_activity_id(int32_t act_id) { activity_id_ = act_id; }
public:
	int32_t activity_id_;//活动ID
	int32_t join_time_;//参加次数
	int32_t timestamp_; // 参加时间
};

typedef std::unordered_map<int32_t, CActivityCount> TActivityDataMap;

class CRoleActivity
{
public:

	CRoleActivity();
	~CRoleActivity();

	bool ReadFromJson(const Json::Value& data_json);
	bool WriteToJson(Json::Value& data_json);
	int32_t GetJoinTimes(int32_t activity_id);
	int32_t ValidJoinTime(int32_t activity_id);
	void AddJoinTime(int32_t activity_id);

	void onNewDay(Player& player);
private:

	TActivityDataMap role_activity_data_;
};

#endif

